home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Include / Libraries / Commodities.i < prev    next >
Text File  |  1997-05-06  |  9KB  |  270 lines

  1. {$I "Include:Devices/InputEvent.i"}
  2. {$I "Include:Devices/KeyMap.i"}
  3. {$I "Include:Exec/Ports.i"}
  4.  
  5. VAR CxBase : Address;
  6.  
  7. {    **************
  8.  * Broker stuff
  9.  **************}
  10.  
  11. CONST
  12. {     buffer sizes   }
  13.       CBD_NAMELEN   =  24;
  14.       CBD_TITLELEN  =  40;
  15.       CBD_DESCRLEN  =  40;
  16.  
  17. {     CxBroker errors   }
  18.       CBERR_OK      =  0;        {     No error                         }
  19.       CBERR_SYSERR  =  1;        {     System error , no memory, etc    }
  20.       CBERR_DUP     =  2;        {     uniqueness violation             }
  21.       CBERR_VERSION =  3;        {     didn't understand nb_VERSION     }
  22.  
  23.       NB_VERSION    =  5;        {     Version of NewBroker structure   }
  24.  
  25. Type
  26.   NewBroker = Record
  27.    nb_Version   : Byte;  {     set to NB_VERSION                }
  28.    nb_Name,
  29.    nb_Title,
  30.    nb_Descr     : String;
  31.    nb_Unique,
  32.    nb_Flags     : Short;
  33.    nb_Pri       : Byte;
  34.    {     new in V5   }
  35.    nb_Port      : MsgPortPtr;
  36.    nb_ReservedChannel  : Short;  {     plans for later port sharing     }
  37.   END;
  38.   NewBrokerPtr = ^NewBroker;
  39.  
  40. CONST
  41. {     Flags for nb_Unique }
  42.       NBU_DUPLICATE  = 0;
  43.       NBU_UNIQUE     = 1;        {     will not allow duplicates        }
  44.       NBU_NOTIFY     = 2;        {     sends CXM_UNIQUE to existing broker }
  45.  
  46. {     Flags for nb_Flags }
  47.         COF_SHOW_HIDE = 4;
  48.  
  49. {    *******
  50.  * cxusr
  51.  *******}
  52.  
  53. {    * Fake data types for system private objects   }
  54. Type
  55.   CxObj = Integer;
  56.   CxObjPtr = ^CxObj;
  57.   CxMsg = Integer;
  58.   CXMsgPtr = ^CxMsg;
  59.  
  60.  
  61. CONST
  62. {    ******************************}
  63. {    * Commodities Object Types   *}
  64. {    ******************************}
  65.       CX_INVALID     = 0;     {     not a valid object (probably null)  }
  66.       CX_FILTER      = 1;     {     input event messages only           }
  67.       CX_TYPEFILTER  = 2;     {     filter on message type      }
  68.       CX_SEND        = 3;     {     sends a message                     }
  69.       CX_SIGNAL      = 4;     {     sends a signal              }
  70.       CX_TRANSLATE   = 5;     {     translates IE into chain            }
  71.       CX_BROKER      = 6;     {     application representative          }
  72.       CX_DEBUG       = 7;     {     dumps kprintf to serial port        }
  73.       CX_CUSTOM      = 8;     {     application provids function        }
  74.       CX_ZERO        = 9;     {     system terminator node      }
  75.  
  76. {    ***************}
  77. {    * CxMsg types *}
  78. {    ***************}
  79.       CXM_UNIQUE     = 16;    {     sent down broker by CxBroker()      }
  80. {     Obsolete: subsumed by CXM_COMMAND (below)   }
  81.  
  82. {     Messages of this type rattle around the Commodities input network.
  83.  * They will be sent to you by a Sender object, and passed to you
  84.  * as a synchronous function call by a Custom object.
  85.  *
  86.  * The message port or function entry point is stored in the object,
  87.  * and the ID field of the message will be set to what you arrange
  88.  * issuing object.
  89.  *
  90.  * The Data field will point to the input event triggering the
  91.  * message.
  92.  }
  93.       CXM_IEVENT     = 32;
  94.  
  95. {     These messages are sent to a port attached to your Broker.
  96.  * They are sent to you when the controller program wants your
  97.  * program to do something.  The ID field identifies the command.
  98.  *
  99.  * The Data field will be used later.
  100.  }
  101.       CXM_COMMAND    = 64;
  102.  
  103. {     ID values   }
  104.       CXCMD_DISABLE   = (15);   {     please disable yourself       }
  105.       CXCMD_ENABLE    = (17);   {     please enable yourself        }
  106.       CXCMD_APPEAR    = (19);   {     open your window, if you can  }
  107.       CXCMD_DISAPPEAR = (21);   {     go dormant                    }
  108.       CXCMD_KILL      = (23);   {     go away for good              }
  109.       CXCMD_UNIQUE    = (25);   {     someone tried to create a broker
  110.                                * with your name.  Suggest you Appear.
  111.                                }
  112.       CXCMD_LIST_CHG  = (27);  {     Used by Exchange program. Someone }
  113.                               {     has changed the broker list       }
  114.  
  115. {     return values for BrokerCommand(): }
  116.       CMDE_OK        = (0);
  117.       CMDE_NOBROKER  = (-1);
  118.       CMDE_NOPORT    = (-2);
  119.       CMDE_NOMEM     = (-3);
  120.  
  121. {     IMPORTANT NOTE: for V5:
  122.  * Only CXM_IEVENT messages are passed through the input network.
  123.  *
  124.  * Other types of messages are sent to an optional port in your broker.
  125.  *
  126.  * This means that you must test the message type in your message handling,
  127.  * if input messages and command messages come to the same port.
  128.  *
  129.  * Older programs have no broker port, so processing loops which
  130.  * make assumptions about type won't encounter the new message types.
  131.  *
  132.  * The TypeFilter CxObject is hereby obsolete.
  133.  *
  134.  * It is less convenient for the application, but eliminates testing
  135.  * for type of input messages.
  136.  }
  137.  
  138. {    ********************************************************}
  139. {    * CxObj Error Flags (return values from CxObjError())  *}
  140. {    ********************************************************}
  141.       COERR_ISNULL      = 1;  {     you called CxError(NULL)            }
  142.       COERR_NULLATTACH  = 2;  {     someone attached NULL to my list    }
  143.       COERR_BADFILTER   = 4;  {     a bad filter description was given  }
  144.       COERR_BADTYPE     = 8;  {     unmatched type-specific operation   }
  145.  
  146.  
  147. {    ****************************}
  148. {     Input Expression structure }
  149. {    ****************************}
  150.  
  151.       IX_VERSION        = 2;
  152.  
  153. Type
  154.   InputXpression = Record
  155.    ix_Version,               {     must be set to IX_VERSION  }
  156.    ix_Class    : Byte;       {     class must match exactly   }
  157.  
  158.    ix_Code     : Short;      {     Bits that we want  }
  159.  
  160.    ix_CodeMask : Short;      {     Set bits here to indicate  }
  161.                              {     which bits in ix_Code are  }
  162.                              {     don't care bits.           }
  163.  
  164.    ix_Qualifier: Short;      {     Bits that we want  }
  165.  
  166.    ix_QualMask : Short;      {     Set bits here to indicate  }
  167.                            {     which bits in ix_Qualifier }
  168.                                                    {     are don't care bits        }
  169.  
  170.    ix_QualSame : Short;    {     synonyms in qualifier      }
  171.   END;
  172.   InputXpressionPtr = ^InputXpression;
  173.  
  174.    IX = InputXpression;
  175.    IXPtr = ^IX;
  176.  
  177. CONST
  178. {     QualSame identifiers }
  179.       IXSYM_SHIFT = 1;     {     left- and right- shift are equivalent     }
  180.       IXSYM_CAPS  = 2;     {     either shift or caps lock are equivalent  }
  181.       IXSYM_ALT   = 4;     {     left- and right- alt are equivalent       }
  182.  
  183. {     corresponding QualSame masks }
  184.       IXSYM_SHIFTMASK = (IEQUALIFIER_LSHIFT + IEQUALIFIER_RSHIFT);
  185.       IXSYM_CAPSMASK  = (IXSYM_SHIFTMASK    + IEQUALIFIER_CAPSLOCK);
  186.       IXSYM_ALTMASK   = (IEQUALIFIER_LALT   + IEQUALIFIER_RALT);
  187.  
  188.       IX_NORMALQUALS  = $7FFF;   {     for QualMask field: avoid RELATIVEMOUSE }
  189.  
  190.  
  191. FUNCTION ActivateCxObj(co : Address; t : Integer) : Integer;
  192.     External;
  193.  
  194. PROCEDURE AddIEvents(IE : InputEventPtr);
  195.     External;
  196.  
  197. PROCEDURE AttachCxObj(headObj : CxObjPtr; co : CxObjPtr);
  198.     External;
  199.  
  200. PROCEDURE ClearCxObjError(co : CxObjPtr);
  201.     External;
  202.  
  203. FUNCTION CreateCxObj(Typ, Arg1, Arg2 : Integer) : CxObjPtr;
  204.     External;
  205.  
  206. FUNCTION CxBroker(nb : NewBrokerPtr; error : Integer) : CxObjPtr;
  207.     External;
  208.  
  209. FUNCTION CxMsgData(cxm : CxMsgPtr) : Address;
  210.     External;
  211.  
  212. FUNCTION CxMsgID(cxm : CxMsgPtr) : Integer;
  213.     External;
  214.  
  215. FUNCTION CxMsgType(cxm : CxMsgPtr) : Integer;
  216.     External;
  217.  
  218. FUNCTION CxObjError(co : CxObjPtr) : Integer;
  219.     External;
  220.  
  221. FUNCTION CxObjType(co : CxObjPtr) : Integer;
  222.     External;
  223.  
  224. PROCEDURE DeleteCxObj(co : CxObjPtr);
  225.     External;
  226.  
  227. PROCEDURE DeleteCxObjAll(co : CxObjPtr);
  228.     External;
  229.  
  230. PROCEDURE DisposeCxMsg(cxm : CxMsgPtr);
  231.     External;
  232.  
  233. PROCEDURE DivertCxMsg(cxm : CxMsgPtr; headObj, ReturnObj : CxObjPtr);
  234.     External;
  235.  
  236. PROCEDURE EnqueueCxObj(HeadObj, co : CxObjPtr);
  237.     External;
  238.  
  239. PROCEDURE InsertCxObj(headObj, co, pred : CxObjPtr);
  240.     External;
  241.  
  242. FUNCTION InvertKeyMap(ansicode : Integer; event : InputEventPtr; km : KeyMapPtr) : Boolean;
  243.     External;
  244.  
  245. FUNCTION ParseIX(description : String; i : IXPtr) : Integer;
  246.     External;
  247.  
  248. PROCEDURE RemoveCxObj(co : CxObjPtr);
  249.     External;
  250.  
  251. PROCEDURE RouteCxMsg(cxm : CxMsgPtr; co : CxObjPtr);
  252.     External;
  253.  
  254. PROCEDURE SetCxObjPri(co : CxObjPtr; pri : Integer);
  255.     External;
  256.  
  257. PROCEDURE SetFilter(co : CxObjPtr; txt : String);
  258.     External;
  259.  
  260. PROCEDURE SetFilterIX(filter : CxObjPtr; i : IXPtr);
  261.     External;
  262.  
  263. PROCEDURE SetTranslate(translator : CxObjPtr; Events : InputEventPtr);
  264.     External;
  265.  
  266. { functions in V38 and higher (Release 2.1) }
  267.  
  268. FUNCTION MatchIX(event : InputEventPtr; i : IXPtr) : Boolean;
  269.     External;
  270.